﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Enter.Entity;
using Enter.Common;
using Enter.BizLogic;
using Enter.Config;
using Enter.Web.SystemAdmin;
namespace WebSystemAdmin.GoodClass
{
    public partial class GoodClassSpecialsEdit : PageBase
    {

        public int ID = RequestStrHelper.GetIntFromRequest("ID", 0);
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ListCtrlHelper.BindEnumOnListControl(ddl_Status, typeof(EnumStatus));
                if (ID != 0)
                {
                    GetInfo();
                }
            }
        }

        private void GetInfo()
        {
            T111_GoodClassSpecialsBLLSub bll = new T111_GoodClassSpecialsBLLSub();
            T111_GoodClassSpecialsEntity model = bll.GetObjectByID(int.Parse(Request.QueryString["ID"]));
            if (model == null) return;
            txt_ID.Text = model.ID.ToString();
            txt_ShowTop.Text = model.ShowTop.ToString();
            txt_ShowLeft.Text = model.ShowLeft.ToString();
            txt_width.Text = model.width.ToString();
            txt_height.Text = model.height.ToString();
            txt_FatherClassNo.Text = model.FatherClassNo.ToString();
            txt_ClassNo.Text = model.ClassNo.ToString();
            txt_ImgUrl.Text = model.ImgUrl.ToString();
            txt_LinkUrl.Text = model.LinkUrl.ToString();
            txt_Weight.Text = model.Weight.ToString();
            txt_StartTime.Text = model.StartTime.ToString();
            txt_EndTime.Text = model.EndTime.ToString();
            this.ddl_Status.Items.FindByValue(((byte)model.Status).ToString()).Selected = true;
            txt_Descr.Text = model.Descr.ToString();
            txt_AddTime.Text = model.AddTime.ToString();
        }

        protected void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                T111_GoodClassSpecialsEntity model = new T111_GoodClassSpecialsEntity();
                T111_GoodClassSpecialsBLLSub bll = new T111_GoodClassSpecialsBLLSub();
                if (Request.QueryString["ID"] != null)
                {
                    model.ID = ID;
                }
                model.ShowTop = int.Parse(txt_ShowTop.Text);
                model.ShowLeft = int.Parse(txt_ShowLeft.Text);
                model.width = int.Parse(txt_width.Text);
                model.height = int.Parse(txt_height.Text);
                model.FatherClassNo = txt_FatherClassNo.Text;
                model.ClassNo = txt_ClassNo.Text;
                model.ImgUrl = txt_ImgUrl.Text;
                model.LinkUrl = txt_LinkUrl.Text;
                model.Weight = int.Parse(txt_Weight.Text);
                model.StartTime = DateTime.Parse(txt_StartTime.Text);
                model.EndTime = DateTime.Parse(txt_EndTime.Text);
                model.Status = (EnumStatus)byte.Parse(ddl_Status.SelectedValue);
                model.Descr = txt_Descr.Text;
                model.AddTime = DateTime.Parse(txt_AddTime.Text);
                if (bll.Save(model))
                {
                    Utils.throwErrorGotoURL("操作成功", "GoodClassSpecialsList.aspx");
                }
                else
                {
                    Utils.ShowMessage("操作失败");
                }
            }
            catch (Exception ex)
            {
                Utils.ShowMessage("添加失败:" + ex.Message);
            }
        }
    }
}
